#ifndef CUCKOOHASH_H
#define CUCKOOHASH_H

#include <string>
#include <vector>
#include "LinkedList.h"
// Edit by PassLink.cn


namespace ns3
{
class CuckooHash
{
private:
    std::vector<std::pair<std::string, std::int32_t>> table1;
    std::vector<std::pair<std::string, std::int32_t>> table2;
    // 插入节点
    LinkedList nodeList;
    // Kick
    int KickCount = 0;
    // 剔除阈值
    int KickLimts = 10;
    // 哈希表大小
    int table_size;
    // 哈希表容量
    int table1_capacity;
    int table2_capacity;
    int hash_function1(const std::string &key);
    int hash_function2(const std::string &key);

public:
    // 哈希表初始化
    CuckooHash(int initialSize);

    // 插入操作
    bool insert_into(const std::string &key, const std::int32_t &value);

    // 查询键值是否存在
    int32_t search(const std::string &key);

    // 清空哈希表内存
    void clearMemory();

    // 删除键值对
    void remove(const std::string &key);
    //计算阈值，返回Gk是否大于阈值
    bool isFloodStreamflow(const std::string &key);

    // 打印table1的内容
    void printTable();
};
} //space
#endif /* CUCKOOHASH_H */
